import { deepStrictEqual, strictEqual } from 'assert';

import { ConverterBase } from './base';
import { Layout } from './cc';
import { GridConverter as Self } from './grid';

describe('src/scene/service/converter/grid.ts', () => {
    describe('.convert()', () => {
        it('ok', async () => {
            const self = new Self(null as any, null as any, null as any, null as any);

            const layout = {
                type: null
            };
            const node = {
                children: [{
                    position: null
                }],
                addComponent: (arg: any) => {
                    strictEqual(arg, Layout);
                    return layout;
                }
            };
            Reflect.set(self, 'createNode', () => {
                return node;
            });

            Reflect.set(self, 'appendUITransfrom', (arg: any) => {
                strictEqual(arg, node);
            });

            ConverterBase.getCcPropFunc = (arg: any) => {
                return Layout;
            };

            Reflect.set(self, 'addChildren', (arg: any) => {
                strictEqual(arg, node);
            });

            Reflect.set(self, 'createVec3', (arg: any, arg1: any) => {
                strictEqual(arg, 0);
                strictEqual(arg1, 0);
                return 'posi';
            });

            const res = await self.convert();
            strictEqual(res, node);
            strictEqual(layout.type, Layout.Type.GRID);
            deepStrictEqual(node.children, [{
                position: 'posi'
            }]);
        });
    });
})